package cn.edu.nju.common;

import java.util.LinkedList;
import java.util.Queue;

/**     
 * 类名称：Agent    
 * 类描述：     agent节点类
 *     
 */
public class Agent {
	private double tb; ///净利润
	private double vis; //可视度
	private double pa0; //受到二次影响的基准可能
	private double fai = 0.5; //二次衰减习俗

	private double y;
	private double kac;
	/****从原来的assetcom分离出来，放入一个类里***/
	private double init_asset; //初始资产
	private double e; //agent周期回复的最小值ε
	private double k;//agent回复速率指标k

	public static double U; //破产阈值
	private double currentAsset; //当前资产
	private double aerfa;//逆向影响的衰减系数α

	private boolean isBankruptcy = false;//是否破产

	private BankruptcyMessage message;
	private Queue<BankruptcyMessage> msg_queue = new LinkedList<BankruptcyMessage>();//消息队列

	/**    
	 * 方法作用：  消息队列
	 * @return      
	*/
	public void informAgent(BankruptcyMessage message) {
		msg_queue.add(message);
		
	}

	/**    
	 * 方法作用：  对破产的反应
	 * @return      
	*/
	public void responseToBankrupt() {
		double receive_value;
		if (message.isReverse()) {
			receive_value = message.getValue() * this.aerfa;
		} else {
			receive_value = message.getValue();
		}
		this.currentAsset -= receive_value;

	}

	/**    
	 * 方法作用：  判断是否破产，破产了返回true，否则返回false
	 * @return      
	*/
	public boolean isBankCrupt() {
		if (currentAsset < U)
			return true;
		return false;
	}

	/**    
	 * 方法作用：  判断是否破产，破产的话，做出反应，否则什么都不做
	 * @return      
	*/
	public void judgeBankrupt() {
		if (this.isBankCrupt()) {
			//todo  破产的反应，公司自身的属性
		}
		//否则，什么都不做
	}

	/**    
	 * 方法作用：  受到抑制力后的agent反应
	 * @return      
	*/
	public void endureForceResponce(double F) {
		this.currentAsset -= F;
	}

	public double getTb() {
		return tb;
	}

	public void setTb(double tb) {
		this.tb = tb;
	}

	public double getVis() {
		return vis;
	}

	public void setVis(double vis) {
		this.vis = vis;
	}

	public double getPa0() {
		return pa0;
	}

	public void setPa0(double pa0) {
		this.pa0 = pa0;
	}

	public double getFai() {
		return fai;
	}

	public void setFai(double fai) {
		this.fai = fai;
	}

	public double getY() {
		return y;
	}

	public void setY(double y) {
		this.y = y;
	}

	public double getKac() {
		return kac;
	}

	public void setKac(double kac) {
		this.kac = kac;
	}

	public double getInit_asset() {
		return init_asset;
	}

	public void setInit_asset(double init_asset) {
		this.init_asset = init_asset;
	}

	public double getE() {
		return e;
	}

	public void setE(double e) {
		this.e = e;
	}

	public double getK() {
		return k;
	}

	public void setK(double k) {
		this.k = k;
	}

	public double getCurrentAsset() {
		return currentAsset;
	}

	public void setCurrentAsset(double currentAsset) {
		this.currentAsset = currentAsset;
	}

}
